#ifndef COOLPOOL_SIMULATION_DETECTIONCHECKWORKER_H_
#define COOLPOOL_SIMULATION_DETECTIONCHECKWORKER_H_

#include "Collision.h"
#include "CollisionDetectionWorkCollector.h"
#include "CollisionTimeFinder.h"

namespace coolpool
{
	// Unit for parallel processing of collision detection.
	// When one iteration of detection is done it writes an number to the done_ vector.
	// Because the threads are not created in each frame, the synchronization is a bit more complicated.
	class DetectionCheckWorker
	{
	public:

		DetectionCheckWorker(CollisionTimeFinder * collision_time_finder, CollisionDetectionWorkCollector * work_collector, std::vector<int> * done);
		virtual ~DetectionCheckWorker();

		void kill();
		void run();

	private:

		// Done vector.
		std::vector<int> * done_;

		// The main loop executor.
		bool kill_;

		// Collision time finder which is used for detection.
		CollisionTimeFinder * collision_time_finder_;

		// Employer.
		CollisionDetectionWorkCollector * work_collector_;
	};
}

#endif
